package com.xbongbong.paas.elasticsearch.pojo.dto;

import com.xbongbong.paas.domain.entity.ext.ConditionsEntityExt;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.LinkFormPoJo;
import com.xbongbong.paas.field.RelyPoJo;
import com.xbongbong.paas.pojo.ShareConditionFormatPojo;
import com.xbongbong.paas.pojo.dto.SearchInConditionDTO;
import com.xbongbong.paas.toolbox.wrap.QueryIgnore;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.elasticsearch.index.query.BoolQueryBuilder;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: wufeng
 * @date: 2018/10/29 10:49
 * @desrcption: 流程流转条件检索数据
 */
@Getter
@Setter
@ToString
public class SearchDataInConditionDTO extends SearchInConditionDTO {
    private static final long serialVersionUID = 1323921771631707405L;
    /**
     * 菜单id
     */
    private Long menuId;

    /**
     * 表单id
     */
    private Long formId;

    /**
     * 应用id
     */
    private Long appId;


    /**
     * 字段标识
     */
    @NotBlank(message = "字段标识不能为空")
    private String attr;

    /**
     * 原始attr
     */
    private String originalAttr;
    /**
     * 子表单字段标识
     */
    private String subAttr;

    /**
     * 字段类型不能为空
     */
/*    @NotNull(message = "字段类型不能为空")
    private Integer fieldType;*/
    /**
     * 页数
     */
    private Integer page;

    /**
     * 每页行数
     */
    private Integer pageSize;

    @NotNull(message = "saasMark不能为空")
    private Integer saasMark;

    /**
     * 业务类型
     * @see com.xbongbong.saas.enums.XbbRefTypeEnum
     */
    private Integer businessType;
    /**
     * 业务类型
     * @see com.xbongbong.saas.enums.XbbRefTypeEnum
     */
    private Integer subBusinessType;
    /**
     * 删除标记
     */
    private Integer del;

    /**
     * 数据联动
     */
    private RelyPoJo rely;
    /**
     * 关联其他表单
     */
    private LinkFormPoJo linkForm;

    /**
     * 模糊搜索的值
     */
    private Object value;

    /**
     * displayField对应的值
     */
    private Object[] displayFieldValue;

    /**
     * 关联表的查询条件
     */
    private BoolQueryBuilder relyBoolQueryBuilder;

    /**
     * 分组id
     */
    private Long listGroupId;

    /**
     * 是否默认分组
     */
    private Integer defaultGroup;

    /**
     * saas列表数据状态
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private Integer statusFilter;

    private List<ConditionsEntityExt> conditionsList;

    private List<List<ConditionsEntityExt>> shouldConditionsList;

     /**
     * 共享权限条件
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private ShareConditionFormatPojo sharePermission;

    /**
     * 多表单限制
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private Boolean limitForms = false;

    /**
     * 多表单
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private List<Long> formIdList;

    /**
     * 需要检索的值
     */
    private List<Object> valueList;

    /**
     * 预览字段列表
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private List<FieldAttrEntity> previewFieldList;

    /**
     * 来自哪个接口的请求（目前已知流程和首页看板设置都会调用这个接口）
     * @see com.xbongbong.saas.enums.SearchDataFromEnum
     */
    private String from;

    /**
     * 是否来源于图表
     */
    private Integer forChart;

    /**
     * 是否来源于评分
     */
    private Integer forScore;

    private Integer priceBusinessType;
    /**
     * 对账日期范围筛选：[1601481600, 1603555199]
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private List<Long> checkingDate;
    @Getter(onMethod_ = {@QueryIgnore})
    private Long poolId;
    /**
     * 特殊业务中的特殊字段(eg:WorkOrderV2中的VersionId)
     */
    private String specialField;

    public SearchDataInConditionDTO(){
        page = 1;
        pageSize = 10;
        del = DelEnum.NORMAL.getDel();
        shouldConditionsList = new ArrayList<>();
        conditionsList = new ArrayList<>();
        valueList = new ArrayList<>();
    }
}
